export default app => {
  const { STRING, INTEGER, DATE } = app.Sequelize;

  const organizationType = app.model.define('organization_type', {
    id: { type: INTEGER, primaryKey: true, autoIncrement: true },
    uuid: { type: STRING(36), unique: true },
    name: STRING(10), // 机构类型名
    createdAt: DATE,
    updatedAt: DATE,
  });

  organizationType.associate = () => {
    app.model.OrganizationType.hasMany(app.model.Organization, {
      foreignKey: 'fk_type',
      sourceKey: 'uuid',
    });
    app.model.OrganizationType.hasMany(app.model.Talent, {
      foreignKey: 'type',
      sourceKey: 'uuid',
    });
  };
  return organizationType;
};
